import { instance } from "./api.interceptor"
import { ITheme } from "../interfaces"




export const ThemeService = {
    async getByDisciplineId(disciplineId: number): Promise<ITheme[]> {
        const resp = await instance.get<ITheme[]>(`/theme/by-discipline-id/${disciplineId}`)
        return resp.data
    },
    async getAll(): Promise<ITheme[]> {
        const resp = await instance.get<ITheme[]>(`/theme`)
        return resp.data
    },

    async getOne(themeId:number): Promise<ITheme> {
        const resp = await instance.get<ITheme>(`/theme/${themeId}`)
        return resp.data
    },


    async create(dto: { disciplineId: number, tittle: string, award: number, level:number }): Promise<ITheme> {
        const resp = await instance.post<ITheme>('/theme', dto)
        return resp.data
    },

    async remove(id: number): Promise<ITheme> {
        const resp = await instance.delete<ITheme>(`/theme/${id}`)
        return resp.data
    }

}
